<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台</title>
	 <link rel="stylesheet" type="text/css" href="/css/css.css">
	 <link rel="stylesheet" type="text/css" href="/font-awesome-4.7.0/css/font-awesome.min.css">
	 <link  rel="stylesheet" type="text/css" href="/css/lyz.calendar.css" />
     <script src='/js/jquery.js'></script>
	 <script src='/js/layer.js'></script>
	 <script src='/js/funclayer.js'></script>
	 <script src=''></script>
</head>
<style>
  .class_,.class,.page_a,.a_page{float:left;;text-align:center;line-height:25px;border-radius:3px;font-size:14px; margin-left:4px;}
   .class_{
      background:#efefef;
	  width:60px;
	  height:25px;
	  color:white;
   }
   .class{
       background:#ccffff;
	  width:60px;
	  height:25px;
   }
   .page_a{
      width:20px;
	  height:25px;
	  background:#efefef;
	  margin-left:4px;
	  color:white;
   }
   .a_page{
      width:20px;
	  height:25px;
	  background:#ccffff;
	  margin-left:4px;
   }
</style>
<body>
	{include file='index/public/header'}
<div class="left">
{include file='index/public/left'}
</div>
<div id="right">
	<a href="/admin.php/sp/sp_add" id="fabu" @click='brand_save()'><font style='font-weight:bold;font-size:18px;position:relative;top:2px;'>+</font> 添加商品</a>
<table width="84.8%" border="0" cellspacing="0" cellpadding="0" class="list" >
		<tr style='background:#f2f6fc;height:30px;font-size:13px;color:#666;'>
			<th class="bgtt" width="3%" style='text-align:left;text-indent:8px;'><input type="checkbox" name="checkall" onclick="pe_checkall(this, 'category_id')" style='margin-left:-8px;'/></th>
			<th class="bgtt" width="3%" style='text-align:left;'>ID号</th>
      <th class="bgtt" width="3%" style='text-align:left;'></th>
      <th class="bgtt" width='20%' style='text-align:left;'>商品名称</th>
      <th class="bgtt" width='10%' style='text-align:center;'>分类</th>
      <th class="bgtt" width='10%' style='text-align:left;text-indent:5px;'>品牌</th>
      <th class="bgtt" width='6%' style='text-align:left;text-indent:5px;'>单价</th>
      <th class="bgtt" width='5%' style='text-align:left;'>库存</th>
      <th class="bgtt" width='8%' style='text-align:left;'>销量/评价</th>
			<th class="bgtt" width='10%' style='text-align:left;'>上架</th>
			<th class="bgtt" width="20%" style='text-align:left;'>操作</th>
		</tr>
{volist name="sp" id="vo" }
    <tr style='font-size:13px;'>
     <td ><input type='checkbox' value='1' /></td>
     <td  style='color:#666;' >{$vo.id}</td>
     <td><img src='{$img[$vo.id] | default="/image/file_img.jpg"}' width='42px' height='42px'/></td>
     <td>
       {$vo.sp_name}
     </td>
     <td  style='color:#666;text-align:center;' >{$fl[$vo.fl_id] | default=0}</td>
     <td  style='color:#666;' >{$brand[$vo.brand_id]['brand_name'] | default=0}</td>
     <td  style='color:orange;' >{$stand[$vo.id]['mony'] | default=0}￥</td>
     <td  style='color:#666;' >{$stand[$vo.id]['ku'] | default=0}</td>
     <td  style='color:#666;text-indent:10px;' >{$vo.sp_shop_num | default=0}</td>
     <td  style='color:#666;text-indent:10px;' ><img src='/image/dui.png'/></td>
     <td style='margin-left:100px;'><a href="{:url('/sp/sp_add',['id'=>$vo['id']])}" class='admin_edit' >修改</a> <a href='javascript:;'  onclick='sp_del(this,"{$vo.sp_name}","{$vo.id}")' class='admin_del'>删除</a> <a href='javascript:;' class='starsp' onclick='starsp(this,"{$vo.sp_name}","{$vo.id}")' starsp='{$vo.sp_starsp}'>{$vo.sp_starsp==0?'推荐明星商品':'取消推荐'}</a></td>
    </tr>
{/volist}
		</table>

		<span>{$fy['up_page']}</span> <span style='margin-left:10px;'>{$fy['number_page']}</span> <span>{$fy['down_page']}</span>

</div>
</body>
</html>
<script>


$(function(){
    window.sp_del=function(t,sp_name,id){
		    _.confirm('确定删除','删除商品',function(){
			      $.ajax({
				      url:'/admin.php/sp/sp_del',
					  data:{id:id},
					  dataType:'json',
                      type:'post',
					  success:function(res){
					     if(res.status=='ok'){
						     _.msg('删除成功！',1,1600);
							  $(t).parent().parent().remove();
						 }else{
						    _.msg('删除失败！',7,1600)
						 }
					  }
				  });
			  },function(){layer.closeAll();});
	}


     window.starsp=function(t,sp_name,sp_id){
           _.confirm(($(t).attr('starsp')==0?'确定推荐’'+sp_name+'‘为明星商品':'取消明星商品为‘'+sp_name+'’'),'明星商品',function(){
		       $.ajax({
			      url:'/admin.php/sp/sp_starsp',
				  data:{'id':sp_id,'starsp':$(t).attr('starsp')},
				  dataType:'json',
				  type:'post',
				  success:function(res){
				     if(res.status=='ok'){
					     _.msg((res.starsp==0?'取消成功！':'取消失败'),1,1600);
						 $(t).text((res.starsp==0?'推荐明星商品':'取消推荐'));
                         $(t).attr('starsp',res.starsp);
					 }else{
					     _.msg('系统繁忙,请稍后再试！',7,1600)
					  }
				  }
			   });
		   },function(){layer.closeAll();});
      }
});

</script>
<style>
  tr{
    border-bottom:1px solid #ccc;
    }
    .right_main  table tr:hover{
       cursor:pointer;
       background:#efefef;
    }
    .inputtext{
       width:30px;
       height:20px;
    }
.save{
  float:right;
}
   .num{
       width:25px;
       height:20px;
       text-align:center;
       line-height:25px;
       margin-left:25px;
       margin-top:3px;
   }

    .admin_edit,.admin_del,.starsp{border-radius:3px;}
    .admin_edit{
        border:1px solid green;
	color:green;
    }
    .admin_del{
       border:1px solid orange;
	color:orange;
    }
     #fabu{
      background: #09C878;
    padding: 0 10px 0 10px;
    color: #fff;
    float: right;
    margin: 8px 0px 10px 0;
    height: 26px;
    min-width: 26px;
    _width: 10px;
    line-height: 25px;
    border: 1px solid #00c874;
    border-radius: 18px;
    font-size: 12px
    }
	.starsp{
       border:1px solid #3333ff;
	   color:#3333ff;
	}
</style>
